
x = 1575

while len(set(list(str(x)))) > 1:
    if x == 6174:
        print('数字已经是6174')
        break
    else:
        a = sorted(list(str(x)))
        b = int(''.join(a[::-1]))
        c = int(''.join(a))
        x = b-c
        print(x)
else:
    print('有重复数字')